package com.right.health.app.ui.registered.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.magic.basic.adapter.BaseAbsAdapter;
import com.magic.basic.utils.TimeUtil;
import com.right.health.app.R;
import com.right.health.app.bean.DoctorScheduleResponse;
import com.right.health.app.constants.AppConfig;
import com.right.health.app.utils.WeekUtils;

/*
 * Created by hopeliao on 2019-11-23
 *
 */
public class DoctorBottomSheetAdapter extends BaseAbsAdapter<DoctorScheduleResponse.DoctorScheduleInfo> {

    private String mFormat;

    public DoctorBottomSheetAdapter(Context context) {
        super(context);
        mFormat = "%s（%s） %s";
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if(convertView == null) {
            viewHolder = new ViewHolder();

            convertView = mInflater.inflate(R.layout.choose_doctor_dialog_item, null);
            viewHolder.timeTv = (TextView) convertView.findViewById(R.id.ti_time);
            viewHolder.numTv = (TextView) convertView.findViewById(R.id.tv_num);

            convertView.setTag(viewHolder);

        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        DoctorScheduleResponse.DoctorScheduleInfo info = mDataSource.get(position);

        String regdate = TimeUtil.convertTime(AppConfig.FORMAT_TIME, info.regdate);
        String week = WeekUtils.getWeekOfDate(info.regdate);

        viewHolder.timeTv.setText(String.format(mFormat, regdate, week, info.shiftname));
        viewHolder.numTv.setText(info.regleavecount);
        return convertView;
    }

    private class ViewHolder {
        TextView timeTv, numTv;
    }
}
